home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows News 2006 October
/
wn148cd2.iso
/
Windows
/
S'informer
/
Copernic Desktop Search
/
copernicdesktopsearchfr.exe
/
$R0
/
1033
/
RC_DATA
/
RSSJAVASCRIPT
< prev
next >
Wrap
Text File
|
2006-05-31
|
8KB
|
261 lines
/****************************************************************************
* Copyright (c) 2006, Copernic Technologies Inc.
****************************************************************************/
/****************************************************************************
* Summary :
* Function used by rss xslt.
* Description:
* This unit contains the functions related to the rss feed.
* Author:
* Copernic Technologies Inc.
****************************************************************************/
var c_ImageNewsDown = "arrow-news-down.gif";
var c_ImageNews = "arrow-news.gif";
var c_ImageFeed = "arrow.gif";
var c_ImageFeedDown = "arrow-down.gif";
var c_ComleteNewsId = "CompleteNews";
var c_NewsDescId = "News_";
var c_NewsImageId = "NewsImg_";
var c_CookieLimitNewsNumber = "LimitNewsNumber";
var c_FeedBodyId = "FeedBody_";
var c_FeedImgId = "FeedImg_";
var c_FeedHRId = "HR_";
var c_CookieExpandState = "ExpandState"
var c_ContentDiv = "main-content-div";
/*
* Summary:
* Restore saved number of items to display by feed.
*/
function RestorePreferences(){
var SavedCookie = getCookie(c_CookieLimitNewsNumber);
if (SavedCookie !== null){
if(IsNumeric(SavedCookie)){
document.getElementById('ComboNbrItem').value = SavedCookie;
LimitNewsNumber(SavedCookie);
}
}else{
LimitNewsNumber(document.getElementById('ComboNbrItem').value);
}
var SavedCookieExpand = getCookie(c_CookieExpandState);
if (SavedCookieExpand !== null){
if(SavedCookieExpand == 0){
ExpandAllItems(0);
}
if(SavedCookieExpand == 1){
ExpandAllItems(1);
}
}
// Display content
document.getElementById(c_ContentDiv).style.display = "inline";
}
/*
* Summary:
* Validate if a string is numeric.
* Parameter:
* p_Text: Text to validate.
* Returns:
* Return true if all char are numeric, false otherwise.
*/
function IsNumeric(p_Text)
{
var ValidChars = "0123456789";
var IsNumber=true;
var Char;
for (i = 0; i < p_Text.length && IsNumber == true; i++)
{
Char = p_Text.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
IsNumber = false;
}
}
return IsNumber;
}
/*
* Summary:
* Limit the maximum of news displayed by feed.
* This automatically saved this value to a cookie.
* Parameter:
* p_Value: Maximum number of news to display.
*/
function LimitNewsNumber(p_Value){
var AllDiv = document.getElementsByTagName("div");
var UnderscorePos;
for (var i = 0; i < AllDiv.length; i++)
{
if (AllDiv[i].id.substring(0,c_ComleteNewsId.length) == c_ComleteNewsId){
UnderscorePos = AllDiv[i].id.indexOf('_');
if(parseInt(AllDiv[i].id.substring(12,UnderscorePos)) > p_Value){
AllDiv[i].style.display = "none";
}
else{
AllDiv[i].style.display = "inline";
}
}
}
//save this in a cookie
var ExpireDate = new Date();
var today = new Date()
// valid for 1 year
ExpireDate.setTime(today.getTime() + 24*365*3600000);
setCookie(c_CookieLimitNewsNumber,p_Value,ExpireDate,null,null,0);
}
/*
* Summary:
* Show/Hide all news text(expand/colapse).
* Parameter:
* p_ShowItem: Boolean 0=hide 1=show
*/
function ExpandAllItems(p_ShowItem){
var AllDiv = document.getElementsByTagName("div");
for (var i = 0; i < AllDiv.length; i++)
{
if (AllDiv[i].id.substring(0,c_NewsDescId.length) == c_NewsDescId){
if (p_ShowItem){
AllDiv[i].style.display = "inline";
}else{
AllDiv[i].style.display = "none";
}
}
else if ((AllDiv[i].id.substring(0,c_FeedBodyId.length) == c_FeedBodyId) && p_ShowItem){
AllDiv[i].style.display = "inline";
}
else if ((AllDiv[i].id.substring(0,c_FeedHRId.length) == c_FeedHRId) && p_ShowItem){
AllDiv[i].style.display = "inline";
}
}
var AllArrow = document.getElementsByTagName("img");
for (var j = 0; j < AllArrow.length; j++)
{
if (AllArrow[j].id.substring(0,c_NewsImageId.length) == c_NewsImageId){
if (p_ShowItem){
AllArrow[j].src = c_ImageNewsDown;
}else{
AllArrow[j].src = c_ImageNews;
}
}
else if ((AllArrow[j].id.substring(0,c_FeedImgId.length) == c_FeedImgId) && p_ShowItem){
AllArrow[j].src = c_ImageFeedDown;
}
}
//save this in a cookie
var ExpireDate = new Date();
var today = new Date()
// valid for 1 year
ExpireDate.setTime(today.getTime() + 24*365*3600000);
setCookie(c_CookieExpandState,p_ShowItem,ExpireDate,null,null,0);
}
/*
* Summary:
* Hide or show a specific section.
* Parameter:
* p_id: Id number of the section.
* p_Section: Section type. (FEED or NEWS)
*/
function toggle(p_Id, p_Section) {
if(p_Section == "FEED"){
var target_div = c_FeedBodyId + p_Id;
var target_img = c_FeedImgId + p_Id;
var div_handle = document.getElementById(target_div);
var hr_handle = document.getElementById(c_FeedHRId + p_Id);
if(div_handle.style.display == "none"){
document.getElementById(target_img).src = c_ImageFeedDown;
div_handle.style.display = "inline";
hr_handle.style.display = "inline";
}
else{
document.getElementById(target_img).src = c_ImageFeed;
div_handle.style.display = "none";
hr_handle.style.display = "none";
}
}
else if(p_Section == "NEWS"){
var target_div = c_NewsDescId + p_Id;
var target_img = c_NewsImageId + p_Id;
var div_handle = document.getElementById(target_div);
if(div_handle.style.display == "none"){
document.getElementById(target_img).src = c_ImageNewsDown;
div_handle.style.display = "inline";
}
else{
document.getElementById(target_img).src = c_ImageNews;
div_handle.style.display = "none";
}
}
}
/*
* Summary:
* Hide p_DivToHide and show p_DivToShow.
* Parameter:
* p_DivToHide: Id of div section to hide.
* p_DivToShow: Id of div section to show.
*/
function ShowMore(p_DivToHide, p_DivToShow) {
document.getElementById(p_DivToHide).style.display = "none";
document.getElementById(p_DivToShow).style.display = "inline";
}
/****************************************************************
COOKIE FUNCTIONS
*****************************************************************/
/*
* Summary:
* Sets a cookie.
* Parameters:
* p_name: Name of the cookie.
* p_value: Value of the cookie.
* p_expires: Expiration date of the cookie.
* (defaults to end of current session)
* [p_path]: path for which the cookie is valid.
* (defaults to path of calling document)
* [p_domain]: domain for which the cookie is valid.
* (defaults to domain of calling document)
* [p_secure]: Boolean value indicating if the cookie transmission requires
* a secure transmission.
* Notes:
* An argument defaults when it is assigned null as a placeholder
* A null placeholder is not required for trailing omitted arguments
*/
function setCookie(p_name, p_value, p_expires, p_path, p_domain, p_secure) {
var NewCookie = p_name + "=" + escape(p_value) +
((p_expires) ? "; expires=" + p_expires.toGMTString() : "") +
((p_path) ? "; path=" + p_path : "") +
((p_domain) ? "; domain=" + p_domain : "") +
((p_secure) ? "; secure" : "");
document.cookie = NewCookie;
}
/*
* Summary:
* Gets a cookie.
* Parameter:
* p_name: Name of the cookie to read.
*
* Return string containing value of specified cookie or null
* if cookie does not exist
*/
function getCookie(p_name) {
var DocumentCookie = document.cookie;
var Prefix = p_name + "=";
var BeginPosition = DocumentCookie.indexOf("; " + Prefix);
if (BeginPosition == -1) {
BeginPosition = DocumentCookie.indexOf(Prefix);
if (BeginPosition != 0) return null;
} else
BeginPosition += 2;
var EndPosition = DocumentCookie.indexOf(";", BeginPosition);
if (EndPosition == -1)
EndPosition = DocumentCookie.length;
return unescape(DocumentCookie.substring(BeginPosition + Prefix.length, EndPosition));
}